home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 1.0 version / MF3DPC / MFLABELS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-07  |  5.7 KB  |  237 lines  |  [TEXT/dosa]

  1. /*==============================================================================
  2.  *
  3.  *    File:        MFLABELS.C
  4.  *
  5.  *    Function:    Enum/Flags lookup routines
  6.  *
  7.  *    Version:    Metafile:    Version 1.0 3DMF files
  8.  *                Package:    Release #2 of this code
  9.  *
  10.  *    Author(s):    Rick Wong (RWW), Duet Development Corp.
  11.  *                John Kelly (JRK), Duet Development Corp.
  12.  *
  13.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  14.  *
  15.  *    Change History (most recent first):
  16.  *        FB8_JRK    Segmentation
  17.  *        Fabio    Changed file name to 8 characters
  18.  *        F3K_RWW    GeneralPolygonHint.
  19.  *        F3A_RWW    MeshEdges and OrientationStyle.
  20.  *        F2K_RWW    File created.
  21.  *==============================================================================
  22.  */
  23.  
  24. #include "MFLABELS.H"
  25.  
  26. #include "MFERRORS.H"
  27. #include "MFTYPES.H"
  28. #include "MFTEXTUT.H"
  29.  
  30. #if defined(applec) || defined(__MWERKS__) || defined(THINK_C)
  31. #pragma segment __MF3D__
  32. #endif
  33.  
  34. /*==============================================================================
  35.  *    Enum Tables
  36.  *==============================================================================
  37.  */
  38. MF3D_EnumTable gMF3D_BooleanEnum[] =
  39. {    0x00000000,        "False",
  40.     0x00000001,        "True",
  41.     kMF3D_EndTable
  42. };
  43.  
  44. MF3D_EnumTable gMF3D_ShapeHintEnum[] =
  45. {    0x00000000,        "Convex",
  46.     0x00000001,        "Concave",
  47.     0x00000002,        "Complex",
  48.     kMF3D_EndTable
  49. };
  50.  
  51. MF3D_EnumTable gMF3D_FallOffEnum[] =
  52. {    0x00000000,        "None",
  53.     0x00000001,        "Linear",
  54.     0x00000002,        "Exponential",
  55.     0x00000003,        "Cosine",
  56.     kMF3D_EndTable
  57. };
  58.  
  59. MF3D_EnumTable gMF3D_PixelTypeEnum[] =
  60. {    0x00000000,        "RGB8",
  61.     0x00000001,        "RGB16",
  62.     0x00000002,        "RGB24",
  63.     0x00000003,        "RGB32",
  64.     kMF3D_EndTable
  65. };
  66.  
  67. MF3D_EnumTable gMF3D_EndianEnum[] =
  68. {    0x00000000,        "BigEndian",
  69.     0x00000001,        "LittleEndian",
  70.     kMF3D_EndTable
  71. };
  72.  
  73. MF3D_EnumTable gMF3D_BackfacingEnum[] =
  74. {    0x00000000,        "Both",
  75.     0x00000001,        "Culled",
  76.     0x00000002,        "Flipped",
  77.     kMF3D_EndTable
  78. };
  79.  
  80. MF3D_EnumTable gMF3D_FillStyleEnum[] =
  81. {    0x00000000,        "Filled",
  82.     0x00000001,        "Edges",
  83.     0x00000002,        "Points",
  84.     0x00000003,        "Empty",
  85.     kMF3D_EndTable
  86. };
  87.  
  88. MF3D_EnumTable gMF3D_InterpolationStyleEnum[] =
  89. {    0x00000000,        "None",
  90.     0x00000001,        "Vertex",
  91.     0x00000002,        "Pixel",
  92.     kMF3D_EndTable
  93. };
  94.  
  95. MF3D_EnumTable gMF3D_OrientationStyleEnum[] =
  96. {    0x00000000,        "CounterClockwise",
  97.     0x00000001,        "Clockwise",
  98.     kMF3D_EndTable
  99. };
  100.  
  101. MF3D_EnumTable gMF3D_SubdivisionMethodEnum[] =
  102. {    0x00000000,        "Constant",
  103.     0x00000001,        "WorldSpace",
  104.     0x00000002,        "ScreenSpace",
  105.     kMF3D_EndTable
  106. };
  107.  
  108. MF3D_EnumTable gMF3D_AxisEnum[] =
  109. {    0x00000000,        "X",
  110.     0x00000001,        "Y",
  111.     0x00000002,        "Z",
  112.     kMF3D_EndTable
  113. };
  114.  
  115. MF3D_EnumTable gMF3D_ShaderUVBoundaryEnum[] =
  116. {    0x00000000,        "Wrap",
  117.     0x00000001,        "Clamp",
  118.     kMF3D_EndTable
  119. };
  120.  
  121. MF3D_EnumTable gMF3D_PackingEnum[] =
  122. {    0x00000000,        "Include",
  123.     0x00000001,        "Exclude",
  124.     kMF3D_EndTable
  125. };
  126.  
  127. MF3D_EnumTable gMF3D_GeneralPolygonHintEnum[] =
  128. {    0x00000000,        "Complex",
  129.     0x00000001,        "Concave",
  130.     0x00000002,        "Convex",
  131.     kMF3D_EndTable
  132. };
  133.  
  134. /*==============================================================================
  135.  *    Flag Tables
  136.  *==============================================================================
  137.  */
  138. MF3D_FlagTable gMF3D_MetafileFlags[] =
  139. {    0x00000000,        "Normal",
  140.     0x00000001,        "Stream",
  141.     0x00000002,        "Database",
  142.     kMF3D_EndTable
  143. };
  144.  
  145. MF3D_FlagTable gMF3D_DisplayGroupStateFlags[] =
  146. {    0x00000000,        "None",
  147.     0x00000001,        "Inline",
  148.     0x00000002,        "DoNotDraw",
  149.     0x00000004,        "NoBoundingBox",
  150.     0x00000008,        "NoBoundingSphere",
  151.     0x00000010,        "DoNotPick",
  152.     kMF3D_EndTable
  153. };
  154.  
  155. MF3D_FlagTable gMF3D_PickPartsFlags[] =
  156. {    0x00000000,        "Object",
  157.     0x00000001,        "Face",
  158.     0x00000002,        "Edge",
  159.     0x00000004,        "Vertex",
  160.     kMF3D_EndTable
  161. };
  162.  
  163. MF3D_FlagTable gMF3D_CapsFlags[] =
  164. {    0x00000000,        "None",
  165.     0x00000001,        "Bottom",
  166.     0x00000002,        "Top",
  167.     kMF3D_EndTable
  168. };
  169.  
  170. /*==============================================================================
  171.  *    MF3D_MatchLabelByValue
  172.  *
  173.  *    Try to match inValueToMatch in the given label table.
  174.  *    Return the matching string in outLabelText (unless outLabelText is NULL).
  175.  *        Remember to free the string later!
  176.  *==============================================================================
  177.  */
  178. MF3DErr
  179. MF3D_MatchLabelByValue(
  180.     MF3D_LabelTablePtr    inLabelTablePtr,
  181.     const MF3DUns32        inValueToMatch,
  182.     MF3DCStringPtr        *outLabelText)
  183. {
  184.     MF3DErr    result;
  185.  
  186.     /* Assume we will fail to match (rare pessimism) */
  187.     result = kMF3DErrIllegalEnum;
  188.  
  189.     while (inLabelTablePtr->str != NULL)
  190.     {    if (inValueToMatch == inLabelTablePtr->value)
  191.         {    result = kMF3DNoErr;    /* match! */
  192.             if (outLabelText != NULL)
  193.             {    MF3DCStringPtr    str;
  194.                 str = MF3D_DuplicateCString(inLabelTablePtr->str);
  195.                 if (str == NULL)
  196.                     result = kMF3DErrOutOfMemory;
  197.                 else
  198.                     *outLabelText = str;
  199.             }
  200.             break;                    /* ### SUCCESSFUL LOOP EXIT ### */
  201.         }
  202.         ++inLabelTablePtr;
  203.     }
  204.  
  205.     return result;
  206. }
  207.  
  208. /*==============================================================================
  209.  *    MF3D_MatchLabelByName
  210.  *
  211.  *    Try to match inLabelText in the given label table.
  212.  *==============================================================================
  213.  */
  214. MF3DErr
  215. MF3D_MatchLabelByName(
  216.     MF3D_LabelTablePtr    inLabelTablePtr,
  217.     MF3DCStringPtr        inLabelText,
  218.     MF3DUns32            *outLabelValue)
  219. {
  220.     MF3D_LabelTablePtr    labelPtr;
  221.     MF3DErr result;
  222.  
  223.     /* Assume we will fail to match (rare pessimism) */
  224.     result = kMF3DErrIllegalEnum;
  225.  
  226.     for (labelPtr = inLabelTablePtr; labelPtr->str != NULL; ++labelPtr)
  227.     {    if (MF3D_CmpStrInsensitive(inLabelText, labelPtr->str) == 0)
  228.         {    result = kMF3DNoErr;    /* match! */
  229.             if (outLabelValue != NULL)
  230.                 *outLabelValue = labelPtr->value;
  231.             break;                    /* ### SUCCESSFUL LOOP EXIT ### */
  232.         }
  233.     }
  234.  
  235.     return result;
  236. }
  237.